<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;

    }

    ul {
      list-style: none;
      width: 900px;
      margin: 40px auto;
    }

    li {
      float: left;
      width: 150px;
      height: 40px;
      line-height: 40px;
      background-color: yellowgreen;
      text-align: center;
    }

    ul li a {
      display: block;
      text-decoration: none;
      color: yellow;
    }

    ul li a:hover {
      border-top: 4px solid red;
      position: relative;
      top: -4px;
    }

    /*    ul {
      background-color: yellowgreen;
    }

    ul li {
      list-style: none;
      float: left;
      width: 50px;
      height: 60px;
      margin-left: 10px;
      text-align: center;

    }

    ul li a {
      text-decoration: none;
      color: black;
    }

    ul li a:hover {
      border-top: 1px solid #e0088d;
      position: relative;
      left: 0;
      top: 0;

    } */
  </style>
</head>

<body>
  <ul>
    <li><a href="#">首页</a></li>
    <li><a href="#">首页</a></li>
    <li><a href="#">首页</a></li>
    <li><a href="#">首页</a></li>
    <li><a href="#">首页</a></li>
    <li><a href="#">首页</a></li>
  </ul>
</body>

</html>